home *** CD-ROM | disk | FTP | other *** search
- Path: hermes.is.co.za!news
- From: Itsik Rubin <yr@isis.co.za>
- Newsgroups: comp.lang.c++
- Subject: Correctness of RTTI Info in Borland C++ in a multi threaded envirnment
- Date: Wed, 20 Mar 1996 19:26:48 +0200
- Organization: No organisation supplied
- Message-ID: <31503FD8.4A7A@isis.co.za>
- NNTP-Posting-Host: yr.isis.co.za
- Mime-Version: 1.0
- Content-Type: text/html; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0GoldB1 (WinNT; I)
- Content-Disposition: inline; filename="mail.htm"
-
- <BASE HREF="file:///D|/builds/rps00933/rtti/mail.htm">
-
- <html>
- <head>
- <title></title>
- <meta name="GENERATOR" content="Mozilla/2.0GoldB1 (Win32)">
- </head>
- <body>
-
- <p>Hello, </p>
-
- <p>I am using Borland C++ Version 4.51 under Windows NT I am developping
- a 32 bit application that is intended for Windows NT and I use extensively
- multi threading as well as the streaming mechanism provided in the Borland
- class library.</p>
-
- <p>This is used for inter thread , inter process and inter processor (over
- a LAN) communication.</p>
-
- <p>The developped system is required to run continuously 24 hours a day
- 7 days a week.</p>
-
- <p>Approximatly once a day I run into a problem where during the operation
- of the system a stream becomes corrupted. When I make the following change
- to the opstream::WriteData method inside objstrm.cpp (Borland Class library)
- I get logs in both places (marked 1 and 2).</p>
-
- <p>Based on my observation the first _TYPENAME(strmr) is erronous whereas
- the second one returns correct results.</p>
-
- <p>This points to problems within the RTTI mechanism. The following questions
- (at least) need answer: </p>
-
- <p>1. Is typeinfo object, which is part of the Borland C++ RTTI, multi-thread
- safe? </p>
-
- <p>2. Has anyone else encounted this problem? </p>
-
- <p>3. Is there a fix for this problem? </p>
-
- <p>The modified method in objstrm.cpp: (The code preceeded by /**/ is an
- addition.</p>
-
- <p>void opstream::writeData( const TStreamableBase *t, ModuleId mid )</p>
-
- <p>{</p>
-
- <ul>
- <p>if( good() )</p>
-
- <p>{ </p>
-
- <ul>
- <p>registerObject( CONST_CAST(TStreamableBase *,t) );</p>
-
- <p>const ObjectBuilder *res = types->Lookup( mid, _TYPENAME(t) );</p>
-
- <p>CHECKX(res,_TYPENAME(t)); </p>
-
- <p>TStreamer *strmr = res->Builder(CONST_CAST(TStreamableBase *,t));</p>
- </ul>
-
- <p>/**/ if ( t )</p>
-
- <p>/**/ { </p>
-
- <p>/**/ char check [100] ;</p>
-
- <p>/**/ char strmtname [100] ;</p>
-
- <p>/**/ strcpy ( strmtname, _TYPENAME(strmr) ); </p>
-
- <p>/**/ sprintf ( check , "%s::Streamer" , _TYPENAME(t) ) ;</p>
-
- <p>/**/ if ( strcmp ( check , strmtname ) != 0 )</p>
-
- <p>/**/ { </p>
-
- <p>/**/ char temp [200] ; </p>
-
- <p>/**/ sprintf ( temp , "WriteData lookup error %s not equal to %s"
- , check , strmtname ) ; </p>
-
- <p>/* (1) */ cout << temp << endl;</p>
-
- <p>/**/ if ( strcmp ( strmtname, _TYPENAME(strmr) ) != 0 )</p>
-
- <p>/**/ {</p>
-
- <p>/**/ sprintf ( temp, "WriteData changed typeinfo %s to %s",
- strmtname, _TYPENAME(strmr) ) ;</p>
-
- <p>/* (2) */ cout << temp << endl;</p>
-
- <p>/**/ }</p>
-
- <p>/**/ }</p>
-
- <p>/**/ } </p>
-
- <ul>
- <p>writeWord32( strmr->ClassVersion() );</p>
-
- <p>strmr->Write( *this );</p>
-
- <p>delete strmr;</p>
- </ul>
-
- <p>}</p>
- </ul>
-
- <p>}</p>
-
- <ul>
- <p></p>
-
- <p>A response will be greatly appreciated. </p>
-
- <p>Regards, </p>
-
- <p>Itsik Rubin</p>
- </ul>
-
- </body>
- </html>
-
-